const DEFAULT_FILTERS = {
  distId: '',
  projectName: '',
  buildComName: '',
  projectCode: '',
  projectTypeName: '',
  activeType: '0',
  dutyPerName: '',
  dutyPerCard: ''
}

const REGION = {
  province: '',
  city: '',
  area: ''
}

export default {
  namespaced: true,
  state: {
    name: 'project',
    filters: DEFAULT_FILTERS,
    region: REGION
  },
  getters: {
    getName(state) {
      return state.name
    },
    getFilters(state) {
      return state.filters
    },
    getRegion(state) {
      return state.region
    }
  },
  mutations: {
    setFilters(state, filters) {
      state.filters = filters
    },
    resetFilters(state) {
      state.filters = {
        distId: '',
        projectName: '',
        buildComName: '',
        projectCode: '',
        projectTypeName: '',
        activeType: '0',
        dutyPerName: '',
        dutyPerCard: ''
      }
    },
    setRegion(state, region) {
      state.region = { ...state.region, ...region }
    },
    resetRegion(state) {
      state.region = {
        province: '',
        city: '',
        area: ''
      }
    }
  },
  actions: {
    setFilters({ commit }, filters) {
      commit('setFilters', filters)
    },
    resetFilters({ commit }) {
      commit('resetFilters')
    },
    setRegion({ commit }, filters) {
      commit('setRegion', filters)
    },
    resetRegion({ commit }) {
      commit('resetRegion')
    }
  }
}
